<script setup lang="tsx">
import { ref, onMounted } from "vue";
import { getCorpShowApi } from "@/api/enterpriseUserApi";
const data = ref();
import { userCorp } from "./utils/hook";
const { openDialog } = userCorp();
onMounted(() => {
  getCorpShowApi().then(res => {
    let arr = res.result;
    // console.log(arr);
    arr.businessType = getBusinessType(arr.businessType);
    arr.businessLongTerm = getBusinessLongTerm(arr.businessLongTerm);
    businessLicense.value = arr.businessLicense;
    data.value = [arr];
  });
});
function getBusinessType(value) {
  switch (value) {
    case 1:
      return "合资";
    case 2:
      return "独资";
    case 3:
      return "国有";
    case 4:
      return "私营";
    case 5:
      return "全民所有制";
    case 6:
      return "集体所有制";
    case 7:
      return "股份制";
    case 8:
      return "有限责任";
    default:
      return "暂无";
  }
}
function getBusinessLongTerm(value) {
  switch (value) {
    case 1:
      return "长期";
    case 0:
      return "非长期";
    default:
      return "暂无";
  }
}
const businessLicense = ref("123");
const columns = [
  {
    label: "公司全称",
    prop: "name"
  },
  {
    label: "企业代码(企业统一社会信用代码)",
    prop: "socialCode"
  },
  {
    label: "企业简称",
    prop: "shortName"
  },
  {
    label: "组织机构代码",
    prop: "organizationCode"
  },
  {
    label: "邓白氏编码",
    prop: "dunsNumber"
  },
  {
    label: "企业类型",
    prop: "businessType"
  },
  {
    label: "纳税人标识",
    prop: "taxIdentifyNumber"
  },
  {
    label: "企业注册地",
    prop: "registerPlace"
  },
  {
    label: "企业注册详细地址",
    prop: "registerAddress"
  },
  {
    label: "法定代表人",
    prop: "legalPerson"
  },
  {
    label: "企业负责人",
    prop: "principal"
  },
  {
    label: "企业联系电话",
    prop: "phone"
  },
  {
    label: "注册资本(万)",
    prop: "registeredCapital"
  },
  {
    label: "成立时间",
    prop: "foundDate"
  },
  {
    label: "营业期限",
    prop: "businessTerm"
  },
  {
    label: "营业期限-是否长期",
    prop: "businessLongTerm"
  },
  {
    label: "经营范围",
    prop: "businessScope"
  },
  {
    label: "营业执照",
    prop: "businessLicense",
    cellRenderer: () => (
      <el-image
        style="width: 100px; height: 100px"
        src={businessLicense.value}
      />
    )
  }
];
</script>

<template>
  <div>
    <el-scrollbar>
      <PureDescriptions border :data="data" :columns="columns" :column="3" />
    </el-scrollbar>
    <el-scrollbar>
      <el-button type="primary" @click="openDialog">编辑信息</el-button>
    </el-scrollbar>
  </div>
</template>
